<template>
	<view>
		<u-sticky bgColor="#fff">
			<view class="dingbu">
				<view class="" :style="{paddingTop:menutop+'rpx'}">
					<view class="">
						<view class="ershiba xiaocheng">
							<text class="ershiba xiaolv">青呼我为</text>
						</view>
					</view>
					<view class="flexbetween margin_top">
						<view class="flexleft"
							style="padding:15rpx 30rpx;background: #FFFFFF;border-radius: 12rpx;border: 1rpx solid #FFFFFF;width: 65%;">
							<view class="margin_right1">
								<u-icon name="search" size="28"></u-icon>
							</view>
							<input placeholder="输入关键词" type="text" v-model="keywords" confirm-type="search" @confirm="init"/>
						</view>
						<view class="flexright">
							<image style="width: 25rpx;height: 26rpx;margin-right: 6rpx;"
								src="../../static/image/system/jb.png" mode="">
							</image>
							<view class="strongtext xiaohei">青统币:
								<text class="titletext xiaohei" v-if="userInfo">{{userInfo.score || "0"}}</text>
								<text class="titletext xiaohei" v-if="!userInfo">0</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</u-sticky>
		<view class="mainpadding" style="padding-bottom: 150rpx;">
			<view class="dingwei" style="z-index: 1;">
				<u-swiper :list="list1" imgMode="widthFix" keyName="image_text" height="140" indicator circular
					@click="lbtclick($event,list1)"></u-swiper>
			</view>
			<view class="jrbox">
				<view class="sanshier fonweight xiaohei textcenter">关于&加入我们</view>
				<view class="flexbetween margin_top">
					<view class="" v-for="item in toplist" :key="item.id" @click="jumpdetail('/pages/qingcanyu/shetuanxq?id=',item.id)">
						<image style="width: 82rpx;height: 74rpx;" :src="item.image_text" mode="">
						</image>
						<view class="titletext xiaohei textcenter">{{item.name}}</view>
					</view>
					<view class="" @click="jumpdetail('/pages/qingzixun/fengcai?text=','新生代企业家风采')">
						<image style="width: 82rpx;height: 74rpx;" src="../../static/image/system/qiye.jpg" mode="">
						</image>
						<view class="titletext xiaohei textcenter">新生代</view>
					</view>
				</view>
			</view>
			<!--  近期活动-->
			<view class="">
				<view class="flexbetween margin_top" @click="jumpurl('/pages/qingcanyu/gonghuihd')">
					<view class="flexleft">
						<view class="allline margin_right1"></view>
						<view class="sanshier xiaohei">活动报名</view>
					</view>
					<u-icon name="arrow-right" color="#666666"></u-icon>
				</view>
				<view class="margin_top mainpadding ffffff radius dingwei" v-for="item in list.data" :key="item.id" @click="jumpdetail('/pages/qingcanyu/huodongxq?id=',item.id)">
					<view class="flexleft">
						<image class="margin_right2" style="width: 230rpx;height: 168rpx;" :src="item.image_text"
							mode=""></image>
						<view class="" style="width: 50%;">
							<view class="sanshier xiaohei fonweight xiankuan">{{item.name}}</view>
							<view class="ershil xiaohui margin_top1">承办团体:{{item.cbtt_name}}</view>
							<view class="ershil xiaohui margin_top1">参与积分：{{item.score}}青统币</view>
							<view class="ershil xiaohui margin_top1">{{item.bs_starttime_text}}</view>
						</view>
					</view>
					<view class="" :class="item.activityuser.length?'flexbetween':'flexright'">
						<view class="flexleft margin_top" v-if="item.activityuser.length">
							<view class="ershil xiaohui margin_right1">参与人:</view>
							<view class="flexleft">
								<image class="margin_right1" style="width: 56rpx;height: 56rpx;border-radius: 50%;" v-if="index<3"
									:src="ite.user.avatar_text" mode="" v-for="(ite,index) in item.activityuser" :key="ite.id"></image>
								<u-icon name="more-circle-fill" color="#333333" size="28"></u-icon>
							</view>
						</view>
						<view class="ljbtn flexcenter">
							<view class="" style="word-break: break-all; width: 52rpx;">立即报名 </view>
						</view>
					</view>
					
				</view>
			</view>
		</view>
		<tabbar :current="1"></tabbar>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				menutop: 0,
				list1: [],
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				toplist:[],
				keywords:"",
				userInfo:{}
			}
		},
		onShareAppMessage: function(options) {
			return {
				title: '青年汇',
				imageUrl: '',
				path: '/pages/qingzixun/qingzixun'
			}
		},
		onShareTimeline: function() {
			return {
				title: '青年汇',
				imageUrl: '',
				path: '/pages/qingzixun/qingzixun'
			}
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			this.menutop = uni.getMenuButtonBoundingClientRect().top * 2
			// #endif
			this.init()
			this.getbanner()
			this.shetuan()
		},
		onShow() {
			if (httpRequest.checkIsLogin()) {
				this.getuser()
			}else{
				this.userInfo = null
			}
		},
		methods: {
			lbtclick(e, val){ //点击轮播图
				console.log("点击轮播图");
				uni.navigateTo({
					url: "/pages/qingzixun/lbtxq?id="+val[e].id
				})
			},
			getuser(){
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					if (res.code == 1) {
						this.userInfo = res.data
						uni.setStorageSync("invite_code", res.data.invite_code)
					} else {
						this.userInfo = null
					}
				})
			},
			shetuan(){
				httpRequest.request('/api/index/stIndex', 'GET', {
				}).then(res => {
					this.toplist = res.data
				}).catch(err => {})
			},
			init(isPage, page) {
				httpRequest.request("/api/activitycl/activityIndex", 'GET', {
					page: page || 1,
					limit: this.limit,
					type:0,
					keywords:this.keywords
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = this.list;
						if (isPage == true) {
							this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			getbanner() { //获取轮播图
				httpRequest.request('/api/index/getAdvertiseList', 'POST', {
					advertise_position_id: 2,
					is_more: 1
				}).then(res => {
					this.list1 = res.data
				}).catch(err => {})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.ljbtn {
		// position: absolute;
		// right: 24rpx;
		// bottom: 30rpx;
		width: 88rpx;
		height: 88rpx;
		font-weight: 500;
		font-size: 26rpx;
		color: #FFFFFF;
		background: linear-gradient(321deg, #FF8D4D 0%, #FF3D00 100%);
		box-shadow: 4rpx 4rpx 4rpx 0rpx rgba(255, 51, 51, 0.15);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.jrbox {
		z-index: 0;
		position: relative;
		top: -20rpx;
		background-image: url('../../static/image/system/bk.png');
		background-size: 100% 100%;
		box-sizing: border-box;
		width: 100%;
		padding: 50rpx 30rpx 40rpx;
	}

	.dingbu {
		padding: 0 30rpx 30rpx;
		background-size: 100% 100%;
		width: 100%;
		box-sizing: border-box;
		background-image: url('../../static/image/system/toub.png');
	}
</style>